<template>
  <div>
    <div class="box">
      <!-- 项目管理 -->
      <!-- <h1>lsadlaklsdlkaklsdlkalksdlk</h1> -->
    </div>
  </div>
</template>

<script>
import { MhUserLogin, userLogin } from "@/utils";
export default {
  data() {
    return {
      code: "",
    };
  },
  mounted() {
    this.code = this.$route.query.code;
    this.mhlogin();
  },
  methods: {
    // 美华登录
    async mhlogin() {
      let keyCode = localStorage.getItem("code");
      if (keyCode == this.code) return this.$router.push("/myReport");
      let code = this.code;
      let data = await MhUserLogin(code);
      if (data.code == 100) {
        localStorage.setItem("token", data.data.token);
        localStorage.setItem("code", this.code);
        localStorage.setItem("entname", data.data.entname);
        localStorage.setItem("businessid", data.data.customerid);
        this.$router.push("/myReport");
      } else {
        const a = document.createElement("a"); // 动态创建a标签，防止下载大文件时，用户没看到下载提示连续点击
        a.href = "http://81.68.173.125:7701/finance";
        a.click();
      }
    },
    // 登录
    async login() {
      let data = await userLogin();
      if (data.code == 100) {
        localStorage.setItem("token", data.data);
      }
    },
  },
};
</script>

<style lang="scss" scoped>
.box {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: 100vw;
  height: 100vh;
  background-color: #fff;
}
</style>
